<?php
if(isset($_REQUEST['fuseaction_back'])) {
	$fuseaction_back=$_REQUEST['fuseaction_back'];
}else{
	$fuseaction_back = "";
}
$p_from_email = _CONST_WEBMASTER;
$subject = $_ISA_OWNER_NAME;
$v_staff_id = $_SESSION['staff_id'];
$v_record_id_list = $_REQUEST['hdn_record_id_list'];
$arr_all_record_id  = explode(",",$v_record_id_list);
for ($i=0;$i<sizeof($arr_all_record_id);$i++){
	$v_record_id = $arr_all_record_id[$i];
	$v_email = $_REQUEST['hdn_email_'.$v_record_id];
	if ($v_email != ""){
		$v_email_content = $_REQUEST['hdn_email_content_'.$v_record_id];
		_senmail_from_php($p_from_email,$v_email,$subject,$v_email_content);
		//_send_email_from_PHP($v_from_email, $v_email, $subject, $v_email_content,"","","","");
		if(_is_sqlserver()){
			$v_record_work_id = 0;
			$v_date = date("Y/m/d");
			$v_worktype = "GUI_EMAIL_CHO_CONG_DAN";
			$v_result_id = _save_text_to_database('T_TEMP_FILE', 'C_TEXT', $v_email_content);
			$v_file_id = 0;
			$v_filename = "";
			$sql = "Exec Onegate_RecordWorkUpdate " ;
			$sql = $sql . $v_record_work_id;
			$sql = $sql . "," . $v_record_id ;
			$sql = $sql . "," . $v_staff_id;//ID nguoi thuc hien cong viec
			$sql = $sql . ",'" . $v_worktype . "'";
			$sql = $sql . ",'" . $v_date."'";
			$sql = $sql . "," . $v_result_id ;
			$sql = $sql . "," . $v_file_id;
			$sql = $sql . ",'" . $v_filename."'";
			$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
			$rs = $ado_conn->GetRow($sql);
		}
	}
}
//_send_email_from_PHP($p_from_email,$p_list_email_to,$subject,$message, $p_from_name = false, $p_list_cc=false, $p_list_bcc=false, $p_attach_file_path=false);
//_senmail_from_php($p_from_email,$p_list_email_to,$subject,$message);
//exit;
sleep(0);
?>
<form action="index.php"  Name="f_back" method="post">
	<input type="hidden" name="fuseaction" value="<?php echo $fuseaction_back; ?>">
	<input type="hidden" name="fuseaction_back" value="<?php echo $fuseaction_back; ?>">
</form>		
<Script language="javascript">	
	document.forms(0).submit();
</Script> 

